const webpack = require('webpack')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const path = require('path')

const libs = {
  _frame: ['vue', 'vue-router', 'vuex'],
  // _plugins: ['vue-i18n', 'vue-l10n', 'axios']
}

const dllPath = 'public/assets/dll'

module.exports = {
  mode: 'production',
  entry: { ...libs },
  performance: false,
  output: {
    path: path.resolve(__dirname, dllPath),
    filename: '[name].js',
    sourceMapFilename: '[name].map',
    library: '[name]_dll' // 与 DllPlugin.name 保持一致
  },
  plugins: [
    new CleanWebpackPlugin({
      cleanOnceBeforeBuildPatterns: [
        path.resolve(__dirname, dllPath)
      ]
    }),
    new webpack.DllPlugin({
      name: '[name]_dll',
      path: path.resolve(__dirname, dllPath, '[name].manifest.json'),
      context: path.resolve(__dirname)
    })
  ]
}
